using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class COM_ContactMap : EntityTypeConfiguration<COM_Contact>
    {
        public COM_ContactMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.First)
                .HasMaxLength(50);

            this.Property(t => t.Middle)
                .HasMaxLength(50);

            this.Property(t => t.Last)
                .HasMaxLength(50);

            this.Property(t => t.Title)
                .HasMaxLength(50);

            this.Property(t => t.RecordType)
                .HasMaxLength(20);

            this.Property(t => t.RecordID)
                .HasMaxLength(20);

            this.Property(t => t.JobTitle)
                .HasMaxLength(50);

            this.Property(t => t.Division)
                .HasMaxLength(50);

            this.Property(t => t.Rating)
                .HasMaxLength(2);

            this.Property(t => t.Interest)
                .HasMaxLength(2);

            this.Property(t => t.Status)
                .HasMaxLength(2);

            this.Property(t => t.Mode)
                .HasMaxLength(2);

            this.Property(t => t.Subject)
                .HasMaxLength(100);

            this.Property(t => t.COM_CNT_Company)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("COM_Contact");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.First).HasColumnName("First");
            this.Property(t => t.Middle).HasColumnName("Middle");
            this.Property(t => t.Last).HasColumnName("Last");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.RecordType).HasColumnName("RecordType");
            this.Property(t => t.RecordID).HasColumnName("RecordID");
            this.Property(t => t.JobTitle).HasColumnName("JobTitle");
            this.Property(t => t.Notes).HasColumnName("Notes");
            this.Property(t => t.Photo).HasColumnName("Photo");
            this.Property(t => t.Group).HasColumnName("Group");
            this.Property(t => t.Division).HasColumnName("Division");
            this.Property(t => t.Rating).HasColumnName("Rating");
            this.Property(t => t.Interest).HasColumnName("Interest");
            this.Property(t => t.AnnualRevenues).HasColumnName("AnnualRevenues");
            this.Property(t => t.NBEmployees).HasColumnName("NBEmployees");
            this.Property(t => t.Industry).HasColumnName("Industry");
            this.Property(t => t.LeadSource).HasColumnName("LeadSource");
            this.Property(t => t.CreatedON).HasColumnName("CreatedON");
            this.Property(t => t.Owner).HasColumnName("Owner");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Mode).HasColumnName("Mode");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.COM_CNT_Company).HasColumnName("COM_CNT_Company");

            // Relationships
            this.HasOptional(t => t.COM_Group)
                .WithMany(t => t.COM_Contact)
                .HasForeignKey(d => d.Group);
            this.HasOptional(t => t.Name)
                .WithMany(t => t.COM_Contact)
                .HasForeignKey(d => d.Owner);
            this.HasOptional(t => t.SM_LEAD_SOURCE)
                .WithMany(t => t.COM_Contact)
                .HasForeignKey(d => d.LeadSource);

        }
    }
}
